package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.entity.WebsiteMenuEntity;
import io.renren.modules.web.service.WebsiteMenuService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author zyj
 * @email 740916741@qq.com
 * @date 2019-03-19 15:51:31
 */
@RestController
@RequestMapping("sys/websitemenu")
public class SysWebsiteMenuController {
    @Autowired
    private WebsiteMenuService websiteMenuService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("websitemenu:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = websiteMenuService.queryPage(params);

        return R.ok().put("page", page);
    }


    @GetMapping("/son/menu")
    @ApiOperation("获取子类菜单")
    public R sonmenu(){
        List<WebsiteMenuEntity> list  = websiteMenuService.querySonList();
        return R.ok().put("list",list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("websitemenu:info")
    public R info(@PathVariable("id") Integer id){
			WebsiteMenuEntity websiteMenu = websiteMenuService.selectById(id);

        return R.ok().put("websiteMenu", websiteMenu);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("websitemenu:save")
    public R save(@RequestBody WebsiteMenuEntity websiteMenu){
			websiteMenuService.insert(websiteMenu);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("websitemenu:update")
    public R update(@RequestBody WebsiteMenuEntity websiteMenu){
			websiteMenuService.updateById(websiteMenu);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("websitemenu:delete")
    public R delete(@RequestBody Integer[] ids){
			websiteMenuService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
